//
//  ViewController.m
//  lianxi
//
//  Created by MAC on 15-11-5.
//  Copyright (c) 2015年 m. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
{
    UILabel * l;
}

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	self.view.backgroundColor = [UIColor whiteColor];
    l = [UILabel new];
    l.text = @"你好，世界!";
    [l sizeToFit];
    l.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height/2.0);
    l.textColor = [UIColor greenColor];
    [self.view addSubview:l];
    
    //按钮
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn.frame = CGRectMake(100, 100, 100, 44);
    [btn setTitle:@"🔘" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];
    //[btn setTitle:@"你按下了！" forState:UIControlStateSelected];
    [self.view addSubview:btn];
    
    
}

- (void) onClick:(id)sendr
{
    [UIView animateWithDuration:1.6 animations:^{
        l.center = CGPointMake(self.view.frame.size.width/2.0,50);
    }];
    
    //田字
    for (int j = 0; j<4; j++) {
        UIView * linel = [[UIView alloc]initWithFrame:CGRectMake(50+j*100, 50, 3, 200)];
        linel.backgroundColor = [UIColor blackColor];
        for (int k=0; k<3; k++) {
            UIView * linel1 = [[UIView alloc]initWithFrame:CGRectMake(50, 49+k*100, 200, 3)];
            linel1.backgroundColor = [UIColor blackColor];
            [self.view addSubview:linel1];
        }
        
        [self.view addSubview:linel];
    }
    
    //线
    for (int i = 0; i<4; i++) {
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 200, 0, 3)];
        view.backgroundColor = [UIColor yellowColor];
        [self.view addSubview:view];
        
        [UIView animateWithDuration:2.6 animations:^{
            view.center = CGPointMake(self.view.frame.size.width/2.0,50);
        }];
        CGRect rect = view.frame;
        rect.size.width = self.view.frame.size.width;
        view.frame = rect;
        
    }
    
    
    
}

//动画
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [UIView animateWithDuration:2.6 animations:^{
        l.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height - 50);
    }];
    
}




- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
